//
//  SecondViewController.m
//  UI08_3_属性向前页传值
//
//  Created by Scott on 15/5/13.
//  Copyright (c) 2015年 www.lanou3g.com 蓝欧3G. All rights reserved.
//

#import "SecondViewController.h"
#import "MainViewController.h"

@interface SecondViewController ()
@property (nonatomic, retain) UITextField *textField;
@end

@implementation SecondViewController


- (void)dealloc
{
    [_textField release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self buttonView];
    [self textFieldView];
    
}

- (void)buttonView
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(20, 80, 100, 40);
    [button setTitle:@"OK" forState:UIControlStateNormal];
    [self.view addSubview:button];
    [button addTarget:self action:@selector(clicked:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)clicked:(UIButton *)button
{
    
    MainViewController *vc = self.navigationController.viewControllers[0];
    [vc.button setTitle:self.textField.text forState:UIControlStateNormal];
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)textFieldView
{
    self.textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 150, 200, 40)];
    self.textField.borderStyle = 3;
    self.textField.placeholder = @"请输入用户名";
    [self.view addSubview:self.textField];
    [_textField release];
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
